cap log close

global path = "****"


local name= "create_subgroup_cov_files"
local date = "061720"
global logname = "$path/`name'_`date'.log"

clear
set more off
cd "$path"
log using "$logname", replace

use "$path/Data/penalty_sample.dta", clear

rename fpl_frac magi_fpl2015

*Appendix Figure 3

**** 1) Men and Women *****
preserve
cap gen female = gnd_ind == "F"
keep if age_2017>=45 & age_2017 < 65
collapse (count) dep_tin if covered2016-any_dec!=11, by(treatment female covered1718)
rename dep_tin count_ind
save "$path/cov1718_counts_by_gender.dta", replace
restore

**** 2) Married and Unmarried *****
preserve
keep if age_2017>=45 & age_2017 < 65
collapse (count) dep_tin if covered2016-any_dec!=11, by(treatment married covered1718)
rename dep_tin count_ind
save "$path/cov1718_counts_by_married.dta", replace
restore

**** 3) Above/Below Median Income *****
preserve
keep if age_2017>=45 & age_2017 < 65
sum magi_fpl2015, d
gen above_med_inc = magi_fpl2015 > r(p50)
collapse (count) dep_tin if covered2016-any_dec!=11, by(treatment above_med_inc covered1718)
rename dep_tin count_ind
save "$path/cov1718_counts_by_income.dta", replace
restore



log close

